package HttpResponse;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.*;

@WebServlet(name = "GetPicture", value = "/getPicture.do")
public class GetPicture extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("image/jpeg;charset=UTF-8");
        String path = "E:\\Web\\Web项目\\WebProject\\src\\main\\java\\HttpResponse\\usst\\";
        if(request.getParameter("type").equals("1")){
            path = path +"usst.jpeg";
        }
        else{
            path = path +"qinghua.jpeg";
        }
        FileInputStream fis = new FileInputStream(path);
        int size = fis.available();
        byte data[] = new byte[size] ;
        fis.read(data) ;
        fis.close();
        OutputStream os = response.getOutputStream() ;
        os.write(data);
        os.flush();
        os.close();
        System.out.print(" ");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
